import fire
import shutil
from codesecurity.tasks.common.code_api import update_api_name_vocab
import codesecurity.utils.extract as file_extract

def update_vocab(caches_file,overwrite=False):
    update_api_name_vocab(caches_file,overwrite)

def extract_case(file_path,number=1000,split_char='\t',clear_dir=True):
    if clear_dir:
        file_extract.clear()
    
    count=0
    
    with open(file_path,'r') as f:
        lines=f.readlines()
        for line in lines:
            line=line.strip()
            if len(line)==0:
                continue
            parts=line.split(split_char)
            if len(parts)==0:
                continue
            file_extract.file_extract(parts[0])
            count+=1
            if count>=number:
                break
if __name__=="__main__":
    fire.Fire()